package start.demo01.datatype;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import org.junit.Test;
import start.demo01.domain.Bean1;

import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;

public class Map2BeanTest {


    @Test
    public void t0() {
        List<Bean1> list = new ArrayList<>();
        List<String> list2 = new ArrayList<>();
        Bean1 b = new Bean1();
        b.setTime(LocalDateTime.now());
        b.setThrowException(true);
        list.add(b);
        b = new Bean1();
        b.setTime(LocalDateTime.now());
        b.setThrowException(true);
        list.add(b);
        System.out.println(JSON.toJSONString(list));
        list2 = JSONObject.parseObject(JSON.toJSONString(list), List.class);
        list = new ArrayList<>();
        for (Object o : list2) {
            list.add(JSONObject.parseObject(JSON.toJSONString(o), Bean1.class));
        }
        b = JSONObject.parseObject(JSON.toJSONString(list2.get(0)), Bean1.class);
        System.out.println(JSON.toJSONString(list));
        System.out.println(b);
    }
}

